package com.benz.updatepack.ui;

import javax.swing.JPanel;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;

import com.benz.updatepack.ActionHandler;
import com.benz.updatepack.MainDatas;

import javax.swing.JTextArea;
import javax.swing.JButton;
import javax.swing.AbstractAction;
import java.awt.event.ActionEvent;
import javax.swing.Action;
import java.awt.event.ActionListener;
import java.util.ArrayList;

public class InputDetailPanel extends JPanel {
	private JTextField textField_pathSrc;
	private final Action action = new SwingAction();

	/**
	 * Create the panel.
	 */
	public InputDetailPanel() {
		
		JLabel label = new JLabel("源文件目录");
		
		textField_pathSrc = new JTextField();
		textField_pathSrc.setColumns(10);
		
		JLabel label_1 = new JLabel("文件列表（多项间用,隔开）");
		
		JTextArea textArea_filePaths = new JTextArea();
		
		JButton button = new JButton("完成");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
//				MainDatas._packSrcPaths"packFilePaths"
//				MainDatas._packSrcPaths
				String packSrcPath = textField_pathSrc.getText();
				String packFilePaths = textArea_filePaths.getText();
				ActionHandler.exec(MainDatas._packDate, MainDatas._packDestPath+"/"+MainDatas._packName, packSrcPath, packFilePaths);
			}
		});
		button.setAction(action);
		
		JButton button_1 = new JButton("完成并添加下一批文件路径");
		
		JButton button_2 = new JButton("取消此次打包");
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(24)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addComponent(button)
							.addGap(29)
							.addComponent(button_1)
							.addPreferredGap(ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
							.addComponent(button_2))
						.addGroup(groupLayout.createSequentialGroup()
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(label_1)
								.addComponent(label))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(textField_pathSrc, GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE)
								.addComponent(textArea_filePaths, GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE))))
					.addGap(28))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(20)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(label)
						.addComponent(textField_pathSrc, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(28)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(label_1)
						.addComponent(textArea_filePaths, GroupLayout.PREFERRED_SIZE, 161, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(button)
						.addComponent(button_2)
						.addComponent(button_1))
					.addContainerGap())
		);
		setLayout(groupLayout);

	}
	private class SwingAction extends AbstractAction {
		public SwingAction() {
			putValue(NAME, "SwingAction");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
		}
	}
}
